<template>
	<view class="u-skeleton">
		<view style="padding: 20rpx;" v-if="handleDrawer">
			<adetail @approved="approvedProcess" @rejectApprove="rejectApprove" :procInstId="procInstId"
				:formAuth="formAuth" :key="handleTimer" :defaultData="defaultData" ref="editform" :formData="formData"
				:processSettings="processSettings"></adetail>
		</view>
		
	</view>
</template>

<script>
	import adetail from '../approve/comp/adetail.vue'
	export default {
		components: {
			adetail
		},
		data() {
			return {
				showapprove:false,
				procInstId: 0,
				handleDrawer: false,
				list: [{
					name: '待审批'
				}, {
					name: '已审批'
				}, {
					name: '我的申请'
				}],
				current: 0,
				approveData: [],
				isEmpty: false,
				isLast: false,
				start: 0,
				defaultData: {},
				formData: {},
				detailDrawer: false,
				formTimer: null,
				handleTimer: null,
				processKey: '',
				applierChooseList: {},
				formAuth: {}
			}
		},

		onLoad(e) { 
			let formData = uni.getStorageSync('formData')
			console.log(JSON.parse(e.edata),'akdoakdo');
			this.handleRdit(JSON.parse(e.edata),formData)
			uni.setStorageSync('isback',true);
		},
		methods: {
			rejectApprove(val) {
				this.handleDrawer = false;
				this.$refs.grid.query();
			},
			approvedProcess(val) {
				this.handleDrawer = false;
				this.$refs.grid.query();
			},
			// 审批
			handleRdit(e,fdata) {
				this.procInstId = e.procInstId;
				console.log(e, '数据');
				this.defaultData = JSON.parse(fdata);
				this.$request(this.$api['workbench/itemPermConfig'], {
					procInstId: e.procInstId,
					taskId: e.taskId,
				}, data => {
					this.formAuth = data;
					this.$request(this.$api['workbench/formDesign'], {
						procInstId: e.procInstId
					}, res => {
						console.log('进来了吗', res);
						this.processSettings = res.processSettings;
						this.formData = res.formData;
						this.handleDrawer = true;
						this.handleTimer = new Date().getTime();
					})
				})
			},
			showDetails(e) {
				console.log(e, 'dkakdopakod');
				let that = this
				this.$request(this.$api['workbench/doneForm'], {
					procInstId: e.procInstId
				}, data => {
					this.defaultData = data;
					this.$request(this.$api['workbench/doneFormDesign'], {
						procInstId: e.procInstId
					}, res => {
						this.formData = res.formData;
						setTimeout(() => {
							this.detailDrawer = true;
							this.formTimer = new Date().getTime();
						}, 300)
					})
				})
			},
			changeCurrent(index) {
				this.current = index
			},
			getTodolist() {
				if (!this.isLast) {
					let params = {
						limit: 10,
						current: this.start,
						param: {}
					}
					uni.showLoading({
						title: '加载中'
					});
					this.$request(this.$api['workbench/todoPage'], params, data => {
						uni.hideLoading();
						if (data.list.length) {
							this.approveData = this.approveData.concat(data.list)
							if (data.total - params.current - params.limit > 0) {
								this.start += 10
							} else {
								this.isLast = true
							}
						} else {
							this.isEmpty = true
						}
					})

				} else {
					console.log('没数据了')
					this.isEmpty = true
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.btnstyle {
		width: auto;
		padding: 0 16rpx;
		height: 50rpx;
		float: right;
		line-height: 50rpx;
		text-align: center;
		border: 1rpx solid #f2f2f2;
		font-size: 26rpx;
		margin-right: 10rpx;
		border-radius: 10rpx;
		background-color: #11acf1;
		color: #ffffff;
	}

	.searchbox {
		display: inline-block;
		width: auto;
		height: auto;
		margin: 10rpx;
		padding: 10rpx 20rpx;
		border: 1rpx solid #f2f2f2;
	}

	.header {
		width: 100%;
		height: 300rpx;
		position: fixed;
		top: 0;
		background-image: linear-gradient(#11acf1, #ffffff);
	}

	.bodystyle {
		width: 100%;
		height: 95vh;
		margin-top: 70px;
	}

	.menuStyle {
		width: 100%;
		height: 75rpx;
		line-height: 75rpx;
		text-align: center;
		padding: 0 10px;
		font-size: 30rpx;
	}

	.menuborder {
		border-bottom: 2px solid #11acf1;
	}

	.menu {
		width: 22%;
		background-color: #000000;
		margin: 10upx 1%;
	}

	.showCard {
		padding: 20upx;
		width: 94%;
		margin: 20rpx 3%;
		height: 270rpx;
		border: 1upx solid #f2f2f2;
		box-shadow: 1px 1px 5px #f2f2f2;
	}

	.headerStyle {
		width: 100%;
		position: fixed;
		top: 0;
		height: 75rpx;
		background-color: #ffffff;
		z-index: 999;
	}
</style>